<?php
$username = $_POST["username"];
include_once "conn.php";
$sql = "select username from userinfo where username = '$username' ";
$result = mysqli_query($conn, $sql);
$num = mysqli_num_rows($result);
if ($num) {
    $a['error'] = 1;
}
else {
    $a['error'] = 0;
}
echo Json_encode($a);